<script>
import { getAppVersion } from "@/api/common.js";
import { compareVersion } from "@/utils/RegExp.js";
export default {
	
	onShow() {
		
	},
  created() {
    // #ifdef APP-PLUS
    this.upLoad();
    // #endif
  },
  methods: {
    // 版本更新
    upLoad() {
      let parmas = {
        appType: plus.os.name == "Android" ? "ANDROID" : "IOS",
        userType: 3, // 1用户 2专家 3商家
      };
      getAppVersion(parmas).then((res) => {
        if (res.data.code == 200) {
          let info = res.data.result[0];
          plus.runtime.getProperty(plus.runtime.appid, (app) => {
            if (compareVersion(info.version, app.version) == 1) {
              uni.showModal({
                title: `检测到新版本${info.version}，是否更新?`,
                content: `更新内容：\n${info.content || '无'}`,
                success: (res) => {
                  if (res.confirm) {
                    var appurl = info.downloadUrl;
                    plus.runtime.openURL(appurl);
                  }
                },
              });
            }
          });
        }
      });
    },
  },
};
</script>

<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
/*每个页面公共css */
.page {
  width: 100%;
  height: 100%;
  background: #f6f6f6;
}
.submit {
  background: #333;
  border-radius: 20rpx;
  height: 70rpx;
  color: #fff;
  text-align: center;
  margin: 80rpx auto 0 auto;
  line-height: 70rpx;
}
.right-a{
  position: relative;
  background: #333;
  padding: 5rpx 10rpx;
  border-radius: 4rpx;
  color: #fff;
  margin-left: calc(100vw - 200rpx)!important;
  width: fit-content;
}
</style>
